From ab55278795d719166ff3684c06f11ab17ad0a38e Mon Sep 17 00:00:00 2001 From: "kaf24@labyrinth.cl.cam.ac.uk" Date: Tue, 4 Feb 2003 14:15:38 +0000 Subject: [PATCH] bitkeeper revision 1.22.1.4 (3e3fcb0abWl_8ZV_bqeQT5nG7bJXAw) get_unmapped_area.c, mm.h, memory.c, domain.c, dom0_ops.c: Reduced size of 'struct pfn_info'. Domain frame list is now threaded through a list_head. --- xen-2.4.16/common/dom0_ops.c | 27 ++++++----- xen-2.4.16/common/domain.c | 45 ++++++++++++------- xen-2.4.16/common/memory.c | 2 +- xen-2.4.16/include/xeno/mm.h | 2 - .../arch/xeno/mm/get_unmapped_area.c | 10 +---- 5 files changed, 47 insertions(+), 39 deletions(-) diff --git a/xen-2.4.16/common/dom0_ops.c b/xen-2.4.16/common/dom0_ops.c index 64ac9f6308..735f9f0e17 100644 --- a/xen-2.4.16/common/dom0_ops.c +++ b/xen-2.4.16/common/dom0_ops.c @@ -35,21 +35,24 @@ static void build_page_list(struct task_struct *p) unsigned long * list; unsigned long curr; unsigned long page; + struct list_head *list_ent; list = (unsigned long *)map_domain_mem(p->pg_head << PAGE_SHIFT); - curr = p->pg_head; - *list++ = p->pg_head; - page = (frame_table + p->pg_head)->next; - while(page != p->pg_head){ - if(!((unsigned long)list & (PAGE_SIZE-1))){ - curr = (frame_table + curr)->next; - unmap_domain_mem((unsigned long)(list-1) & PAGE_MASK); + curr = page = p->pg_head; + do { + *list++ = page; + list_ent = frame_table[page].list.next; + page = list_entry(list_ent, struct pfn_info, list) - frame_table; + if( !((unsigned long)list & (PAGE_SIZE-1)) ) + { + list_ent = frame_table[curr].list.next; + curr = list_entry(list_ent, struct pfn_info, list) - frame_table; + unmap_domain_mem(list-1); list = (unsigned long *)map_domain_mem(curr << PAGE_SHIFT); } - *list++ = page; - page = (frame_table + page)->next; } - unmap_domain_mem((unsigned long)(list-1) & PAGE_MASK); + while ( page != p->pg_head ); + unmap_domain_mem(list); } long do_dom0_op(dom0_op_t *u_dom0_op) @@ -147,12 +150,14 @@ long do_dom0_op(dom0_op_t *u_dom0_op) int i; unsigned long pfn = op.u.getmemlist.start_pfn; unsigned long *buffer = op.u.getmemlist.buffer; + struct list_head *list_ent; for ( i = 0; i < op.u.getmemlist.num_pfns; i++ ) { /* XXX We trust DOM0 to give us a safe buffer. XXX */ *buffer++ = pfn; - pfn = (frame_table + pfn)->next; + list_ent = frame_table[pfn].list.next; + pfn = list_entry(list_ent, struct pfn_info, list) - frame_table; } } break; diff --git a/xen-2.4.16/common/domain.c b/xen-2.4.16/common/domain.c index 397a8dceb0..15d3351f1b 100644 --- a/xen-2.4.16/common/domain.c +++ b/xen-2.4.16/common/domain.c @@ -356,26 +356,24 @@ unsigned int alloc_new_dom_mem(struct task_struct *p, unsigned int kbytes) temp = free_list.next; /* allocate first page */ - pf = list_entry(temp, struct pfn_info, list); + pf = pf_head = list_entry(temp, struct pfn_info, list); pf->flags |= p->domain; temp = temp->next; list_del(&pf->list); - pf->next = pf->prev = p->pg_head = (pf - frame_table); + INIT_LIST_HEAD(&pf->list); + p->pg_head = pf - frame_table; pf->type_count = pf->tot_count = 0; free_pfns--; - pf_head = pf; /* allocate the rest */ - for(alloc_pfns = req_pages - 1; alloc_pfns; alloc_pfns--){ + for ( alloc_pfns = req_pages - 1; alloc_pfns; alloc_pfns-- ) + { pf = list_entry(temp, struct pfn_info, list); pf->flags |= p->domain; temp = temp->next; list_del(&pf->list); - pf->next = p->pg_head; - pf->prev = pf_head->prev; - (frame_table + pf_head->prev)->next = (pf - frame_table); - pf_head->prev = (pf - frame_table); + list_add_tail(&pf->list, &pf_head->list); pf->type_count = pf->tot_count = 0; free_pfns--; @@ -406,6 +404,7 @@ unsigned int alloc_new_dom_mem(struct task_struct *p, unsigned int kbytes) int final_setup_guestos(struct task_struct * p, dom_meminfo_t * meminfo) { + struct list_head *list_ent; l2_pgentry_t * l2tab; l1_pgentry_t * l1tab; start_info_t * virt_startinfo_addr; @@ -428,10 +427,12 @@ int final_setup_guestos(struct task_struct * p, dom_meminfo_t * meminfo) do_process_page_updates_bh(pgt_updates, 1); pgt_updates++; if(!((unsigned long)pgt_updates & (PAGE_SIZE-1))){ - unmap_domain_mem((void *)((unsigned long)(pgt_updates-1) & PAGE_MASK)); - curr_update_phys = (frame_table + (curr_update_phys >> PAGE_SHIFT))->next - << PAGE_SHIFT; - pgt_updates = (page_update_request_t *)map_domain_mem(curr_update_phys); + unmap_domain_mem(pgt_updates-1); + list_ent = frame_table[curr_update_phys >> PAGE_SHIFT].list.next; + curr_update_phys = list_entry(list_ent, struct pfn_info, list) - + frame_table; + curr_update_phys <<= PAGE_SHIFT; + pgt_updates = map_domain_mem(curr_update_phys); } } unmap_domain_mem((void *)((unsigned long)(pgt_updates-1) & PAGE_MASK)); @@ -549,7 +550,9 @@ int final_setup_guestos(struct task_struct * p, dom_meminfo_t * meminfo) static unsigned long alloc_page_from_domain(unsigned long * cur_addr, unsigned long * index) { - *cur_addr = (frame_table + (*cur_addr >> PAGE_SHIFT))->prev << PAGE_SHIFT; + struct list_head *ent = frame_table[*cur_addr >> PAGE_SHIFT].list.prev; + *cur_addr = list_entry(ent, struct pfn_info, list) - frame_table; + *cur_addr <<= PAGE_SHIFT; (*index)--; return *cur_addr; } @@ -559,6 +562,7 @@ static unsigned long alloc_page_from_domain(unsigned long * cur_addr, */ int setup_guestos(struct task_struct *p, dom0_newdomain_t *params) { + struct list_head *list_ent; char *src, *dst; int i, dom = p->domain; unsigned long phys_l1tab, phys_l2tab; @@ -653,7 +657,10 @@ int setup_guestos(struct task_struct *p, dom0_newdomain_t *params) machine_to_phys_mapping[cur_address >> PAGE_SHIFT] = count; } - cur_address = ((frame_table + (cur_address >> PAGE_SHIFT))->next) << PAGE_SHIFT; + list_ent = frame_table[cur_address >> PAGE_SHIFT].list.next; + cur_address = list_entry(list_ent, struct pfn_info, list) - + frame_table; + cur_address <<= PAGE_SHIFT; } unmap_domain_mem(l1start); @@ -661,7 +668,10 @@ int setup_guestos(struct task_struct *p, dom0_newdomain_t *params) cur_address = p->pg_head << PAGE_SHIFT; for ( count = 0; count < alloc_index; count++ ) { - cur_address = ((frame_table + (cur_address >> PAGE_SHIFT))->next) << PAGE_SHIFT; + list_ent = frame_table[cur_address >> PAGE_SHIFT].list.next; + cur_address = list_entry(list_ent, struct pfn_info, list) - + frame_table; + cur_address <<= PAGE_SHIFT; } l2tab = l2start + l2_table_offset(virt_load_address + @@ -682,7 +692,10 @@ int setup_guestos(struct task_struct *p, dom0_newdomain_t *params) page->flags = dom | PGT_l1_page_table; page->tot_count++; - cur_address = ((frame_table + (cur_address >> PAGE_SHIFT))->next) << PAGE_SHIFT; + list_ent = frame_table[cur_address >> PAGE_SHIFT].list.next; + cur_address = list_entry(list_ent, struct pfn_info, list) - + frame_table; + cur_address <<= PAGE_SHIFT; } page->flags = dom | PGT_l2_page_table; unmap_domain_mem(l1start); diff --git a/xen-2.4.16/common/memory.c b/xen-2.4.16/common/memory.c index 2bd0a0d11e..264cedfc9c 100644 --- a/xen-2.4.16/common/memory.c +++ b/xen-2.4.16/common/memory.c @@ -175,7 +175,7 @@ #include #include -#if 1 +#if 0 #define MEM_LOG(_f, _a...) printk("DOM%d: (file=memory.c, line=%d) " _f "\n", current->domain, __LINE__, ## _a ) #else #define MEM_LOG(_f, _a...) ((void)0) diff --git a/xen-2.4.16/include/xeno/mm.h b/xen-2.4.16/include/xeno/mm.h index e60ca748ad..e99d8e6889 100644 --- a/xen-2.4.16/include/xeno/mm.h +++ b/xen-2.4.16/include/xeno/mm.h @@ -56,8 +56,6 @@ void __free_pages(unsigned long p, int order); */ typedef struct pfn_info { struct list_head list; /* ->mapping has some page lists. */ - unsigned long next; /* used for threading pages belonging */ - unsigned long prev; /* to same domain */ unsigned long flags; /* atomic flags. */ unsigned long tot_count; /* Total domain usage count. */ unsigned long type_count; /* pagetable/dir, or domain-writeable refs. */ diff --git a/xenolinux-2.4.16-sparse/arch/xeno/mm/get_unmapped_area.c b/xenolinux-2.4.16-sparse/arch/xeno/mm/get_unmapped_area.c index 88339f563b..a7b4447589 100644 --- a/xenolinux-2.4.16-sparse/arch/xeno/mm/get_unmapped_area.c +++ b/xenolinux-2.4.16-sparse/arch/xeno/mm/get_unmapped_area.c @@ -56,11 +56,6 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi if (TASK_SIZE - len < addr) return -ENOMEM; - if(current->pid > 100){ - printk(KERN_ALERT "bd240 debug: gua: vm addr found %lx\n", addr); - printk(KERN_ALERT "bd240 debug: gua: first condition %d, %lx, %lx\n",vma, addr + len, vma->vm_start); - printk(KERN_ALERT "bd240 debug: gua: second condition %d\n", direct_mapped(addr)); - } if ((!vma || addr + len <= vma->vm_start) && !direct_mapped(addr)) return addr; @@ -77,10 +72,7 @@ struct list_head *find_direct(struct list_head *list, unsigned long addr) for ( curr = direct_list->next; curr != direct_list; curr = curr->next ) { node = list_entry(curr, direct_mmap_node_t, list); - if( node->vm_start >= addr ){ - printk(KERN_ALERT "bd240 debug: find_direct: hit %lx\n", node->vm_start); - break; - } + if ( node->vm_start >= addr ) break; } return curr; -- 2.30.2